package org.performance.monitor;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class FileParser {
	private LineEater lineEater;

	public FileParser(LineEater lineEater) {
		this.lineEater = lineEater;
	}

	public List<LogRecord> parse(File file) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(file));
		List<LogRecord> records = new ArrayList<LogRecord>();
		String line = null;
		while ((line = reader.readLine()) != null) {
			records.add(lineEater.eat(line));
		}
		return records;
	}
}
